package com.gui.service;

import com.gui.exception.DIYExceptionHandler;
import com.gui.mapper.QuestionMapper;
import com.gui.mapper.UserMapper;
import com.gui.model.Question;
import com.gui.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * PublishService
 *
 * @author guigu
 * @QQ 1170258867
 * @date 2020/6/11
 * @description
 */
@Service
public class PublishService {

    @Autowired
    private QuestionMapper questionMapper;

    public void SaveOrupdate(Question question) throws DIYExceptionHandler {
        if (question.getId()==0){
            question.setGtmCreate(System.currentTimeMillis());
            questionMapper.insertNewPublish(question);
        }else {
            int i = questionMapper.updateQuestion(question);
            if (i==0){
                throw new DIYExceptionHandler("更新错误,可能已经被删除");
            }
        }
    };
}
